package com.example.hotelmanagement.rest;

import com.example.hotelmanagement.common.exception.ErrorCode;
import com.example.hotelmanagement.common.pojo.CommonResult;
import com.example.hotelmanagement.domain.vo.LoginReqVo;
import com.example.hotelmanagement.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static com.example.hotelmanagement.common.exception.enums.GlobalErrorCodeConstants.*;

/**
 * TODO
 *
 * @author chenhetao
 * @version 1.0
 * @className IdentityController
 * @packageName com.example.hotelmanagement.rest
 * @date 2023/6/10 17:27
 */
@RestController
@RequestMapping("/identity")
public class IdentityController {

    @Resource
    private UserService userService;

    @PostMapping("/login")
    public CommonResult<Integer> Login(@RequestBody LoginReqVo loginReqVo) {

        return userService.login(loginReqVo).equals(1L)? CommonResult.success(1):CommonResult.error(LOGIN_DENIED);
    }
}